

*******************
** Study 2: Table 4
*******************


* Combined dataset
use "LondonBridgeAttack2017.dta", replace
gen year = 2017
append using "LondonBridgeAttack2019.dta"
replace year = 2019 if year == .

* Standardize DVs
foreach dv of varlist sec imm britid englid {
sum `dv' if year == 2017
replace `dv' = `dv' / `r(sd)' if year == 2017
sum `dv' if year == 2019
replace `dv' = `dv' / `r(sd)' if year == 2019
}

* 2017
global covars_binaries = "gender1 gender2 gender3 agecat1 agecat2 agecat3 agecat4 agecat5 agecat6 edu1 edu2 edu3 edu4 edu5 edu6 pol_interest1 pol_interest2 pol_interest3 pol_interest4 lr0 lr1 lr2 lr3 lr4 lr5 lr6 lr7 lr8 lr9 lr10 vote2015_1 vote2015_2 vote2015_3 vote2015_4 vote2015_5 vote2015_6 vote2015_7 vote2015_8 vote2015_9 vote2015_10 refvote2016_1 refvote2016_2 refvote2016_3 region1 region2 region3"

foreach dv of varlist sec imm britid englid {
reg `dv' postattack $covars_binaries if statadate == td(02jun2017) | statadate == td(04jun2017)
estimates store `dv'1_2017
reg `dv' postattack $covars_binaries if inrange(statadate,td(01jun2017),td(02jun2017)) | inrange(statadate,td(04jun2017),td(05jun2017))
estimates store `dv'2_2017
reg `dv' postattack $covars_binaries if inrange(statadate,td(31may2017),td(02jun2017)) | inrange(statadate,td(04jun2017),td(06jun2017))
estimates store `dv'3_2017
}


* 2019
global covars_binaries = "gender1 gender2 gender3 agecat1 agecat2 agecat3 agecat4 agecat5 agecat6 edu1 edu2 edu3 edu4 edu5 edu6 pol_interest1 pol_interest2 pol_interest3 lr0 lr1 lr2 lr3 lr4 lr5 lr6 lr7 lr8 lr9 lr10 vote2017_1 vote2017_2 vote2017_3 vote2017_4 vote2017_5 vote2017_6 vote2017_7 vote2017_8 vote2017_9 vote2017_10 vote2017_11 refvote2016_1 refvote2016_2 refvote2016_3 refvote2016_4 region1 region2 region3"

foreach dv of varlist sec imm britid englid {
reg `dv' postattack $covars_binaries if statadate == td(28nov2019) | statadate == td(30nov2019)
estimates store `dv'1_2019
reg `dv' postattack $covars_binaries if inrange(statadate,td(27nov2019),td(28nov2019)) | inrange(statadate,td(30nov2019),td(1dec2019))
estimates store `dv'2_2019
reg `dv' postattack $covars_binaries if inrange(statadate,td(26nov2019),td(28nov2019)) | inrange(statadate,td(30nov2019),td(2dec2019))
estimates store `dv'3_2019
}

* Formally compare 2017 and 2019 effects
foreach dv of varlist sec imm britid englid {
di "`dv'"
qui: suest `dv'1_2017 `dv'1_2019
lincom [`dv'1_2017_mean]postattack - [`dv'1_2019_mean]postattack
qui: suest `dv'2_2017 `dv'2_2019
lincom [`dv'2_2017_mean]postattack - [`dv'2_2019_mean]postattack
qui: suest `dv'3_2017 `dv'3_2019
lincom [`dv'3_2017_mean]postattack - [`dv'3_2019_mean]postattack
}
